package com.karry.mapper;

import com.karry.pojo.Record;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.Date;

public interface RecordMapper {

    //查询全部
    @Select("select * from tb_record;")
    @ResultMap("recordResultMap")
    ArrayList<Record> searchAllRecord();

    //查询做一个分页多条件查询即可
    ArrayList<Record> searchRecordByMore(@Param("type") String type, @Param("userId") int userId, @Param("blogId") int[] blogId, @Param("date") Date date);

    //插入记录
    @Insert("insert into tb_record (r_type, r_user_id, r_blog_id, r_info, r_other) values (#{type}, #{userId}, #{blogId}, #{info}, #{other});")
    int insertRecord(@Param("type") String type, @Param("userId") int userId, @Param("blogId") int blogId, @Param("info") String info, @Param("other") String other);

    @Select("select count(*) from tb_record;")
    int getRecordCount();

    @Select("select * from tb_record limit #{i}, 13;")
    @ResultMap("recordResultMap")
    ArrayList<Record> getRecordListByPage(int i);
}
